package cn.yunxiang.summer.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import cn.yunxiang.summer.system.domain.po.SysVersion;
import cn.yunxiang.summer.system.domain.bo.SysVersionBo;
import cn.yunxiang.summer.system.domain.vo.SysVersionVo;

@Mapper
public interface SysVerisonMapper extends BaseMapper<SysVersion> {

    IPage<SysVersionVo> getList(@Param("page") Page<SysVersion> page, @Param("query") SysVersionBo query);


    @Update("UPDATE sys_version SET status = 0 WHERE platform_type = #{platformType} AND status = 1")
    void disableOtherVersions(String platformType);

    @Update("UPDATE sys_version SET status = 0 " +
        "WHERE platform_type = #{platformType} " +
        "AND status = 1 " +
        "AND id != #{currentId}")  // 排除当前正在修改的版本
    void disableOtherVersion(@Param("platformType") String platformType,
                              @Param("currentId") Long currentId);
}
